function cTree(treeObj,data,imagesPath,root,showAll,selectList){
	var self=this;
	var treeData=[];
	var selectId=null;
	var selectObj=null;
	var selectLastObj=null;
	var selectType=false;
	if(selectList && selectList.length){selectType=true;}
	var images_dot=["dot_folder.gif","dot_folder_open.gif","dot_page.gif"];
	var images_link=["link_head.gif","link_body.gif","link_foot.gif"];
	var images_minus=["minus_head.gif","minus_body.gif","minus_foot.gif"];
	var images_plus=["plus_head.gif","plus_body.gif","plus_foot.gif"];
	var img_width=20;
	if (!imagesPath) {imagesPath="";}
	var childCss=["padding-left:"+img_width+"px;","padding-left:"+img_width+"px;background:url("+imagesPath+images_link[1]+") repeat-y;"];
	this.show=function(){
		treeData=data;
		treeObj.innerHTML="";
		treeObj.appendChild(this.getTree(root,showAll));
	}
	this.getTree=function(id,showAll,css){
		var theData=[];
		var tempData=[];
		for (var i=0;i<treeData.length;i++){
			if(treeData[i][1]==id){
				theData.push(treeData[i]);
			} else {
				tempData.push(treeData[i]);
			}
		}
		treeData = tempData;
		//window.status = treeData.length;
		var img1,img2,nodeCss;		
		var pnode=document.createElement("div");
		pnode.id="tree_node"+id;
		pnode.className="tree_node";
		if(css){this.setCss(pnode,css);}
		for (var i=0; i<theData.length; i++) {
			var cnode=null;
			var id=theData[i][0];
			var hasChild=this.isHasChild(id);
			if (hasChild) {
				if(showAll){
					if (i==theData.length-1) {
						img1=this.image(images_minus[2],id);
						img1.onclick=function(){self.extend(this,this.value)};
						nodeCss=childCss[0];
					} else {
						img1=this.image(images_minus[1],id);
						img1.onclick=function(){self.extend(this,this.value)};
						nodeCss=childCss[1];
					}
					img2=this.image(images_dot[1],id);
					img2.ondblclick=function(){self.extendall(this,this.value)};
					cnode=this.getTree(id,showAll,nodeCss);
				}else{
					if (i==theData.length-1) {
						img1=this.image(images_plus[2],id);
						img1.onclick=function(){self.extend(this,this.value)};
					} else {
						img1=this.image(images_plus[1],id);
						img1.onclick=function(){self.extend(this,this.value)};
					}
					img2=this.image(images_dot[0],id);
					img2.ondblclick=function(){self.extendall(this,this.value)};
				}
			} else {
				if(i==theData.length-1){img1=this.image(images_link[2]);}else{img1=this.image(images_link[0]);}
				img2=this.image(images_dot[2]);
			}
			

			if(selectType){
				var nodeName=document.createElement("span");
				nodeName.value=id;
				nodeName.className="tree_node_name";
				var isChecked=this.checkSelect(id)?'checked="checked"':"";
				var checkbox='<input name="tree_nodes" type="checkbox" id="tree_checkbox'+id+'" value="'+id+'" '+isChecked+' style="vertical-align:middle;" />';
				var label='<label for="tree_checkbox'+id+'">'+checkbox+theData[i][2]+'</label>';
				nodeName.innerHTML=label;
				nodeName.firstChild.onclick=function(){self.treeCheckboxClick(this);};
			}else{
				var nodeName=document.createElement("a");
				nodeName.value=id;
				nodeName.className="tree_node_name";
				if(theData[i][3]){nodeName.href=theData[i][3];}else{nodeName.href="javascript:void(0);";}
				if(theData[i][4]){nodeName.target=theData[i][4];}
				nodeName.onclick=function(){self._treeNodeClick(this)};
				nodeName.onmouseover=function(){self._treeNodeOver(this)};
				
				var title=document.createElement("span");
				title.className="tree_node_name_title";
				title.innerHTML=theData[i][2];
				nodeName.appendChild(title);
				
				var option=document.createElement("span");
				option.value=id;
				option.hasChild=hasChild;
				option.className="tree_node_name_option";
				option.onmouseover=function(){self._treeNodeOptionOver(this)};
				nodeName.appendChild(option);
			
			}
			
			var node=document.createElement("div");
			node.appendChild(img1);
			node.appendChild(img2);
			node.appendChild(nodeName);
			//clear float
			var clear=document.createElement("div");
			this.setCss(clear,"clear:both;");
			node.appendChild(clear);
			//child
			if(cnode){node.appendChild(cnode);}
			pnode.appendChild(node);
		}
		return pnode;
	}
	this.checkSelect=function(id){
		for(var i=0;i<selectList.length;i++){if(selectList[i]==id){return true;}}
		return false;
	}
	this.isHasChild=function(id){
		for(var i=0;i<treeData.length;i++){if(treeData[i][1]==id){return true;}}
		return false;
	}
	this.extend=function(o,id,showAll){
		var img=o.nextSibling;
		var pNode=o.parentNode;
		var cNode=img.nextSibling.nextSibling.nextSibling;
		if(o.src.indexOf(imagesPath+"minus")!=-1){
			o.src=o.src.split("minus").join("plus");
			img.src=img.src.split("folder_open").join("folder");
			if(cNode){cNode.style.display="none";}
		}else{
			o.src=o.src.split("plus").join("minus");
			img.src=img.src.split("folder").join("folder_open");
			if(cNode){
				cNode.style.display="";
			}else{
				if(o.src.indexOf("_foot.gif")==-1){
					nodeCss=childCss[1];
				}else{
					nodeCss=childCss[0];
				}
				o.parentNode.appendChild(this.getTree(id,showAll,nodeCss));
			}
		}
	}
	this.extendall=function(img,id){
		if(id){var o=img.previousSibling;this.extend(o,id,true);}
	}
	this.setCss=function(o,css){
		if (!o || o.nodeType == 3 || o.nodeType == 8){return undefined;}
		try {o.style.cssText=css;} catch(e) {o.setAttribute("style",css);}
	}
	this.image=function(file,id){
		var img=document.createElement("img");
		img.src=imagesPath+file;
		img.width=img_width;
		img.height=img_width;
		img.className="tree_node_image";
		if(id){img.value=id;}
		img.align="absmiddle";	
		return img;
	}
	this.treeCheckboxClick=function(o){}
	this.treeNodeClick=function(obj,id){}
	this._treeNodeClick=function(obj){
		selectObj=obj;
		selectId=obj.value;
		if(!selectType){
			if(selectLastObj){
				selectLastObj.className="tree_node_name";
			}
			obj.className="tree_node_name tree_node_selected";
		}
		selectLastObj=obj;
		this.treeNodeClick(obj,obj.value);
	}
	this.treeNodeOver=function(obj,id){}
	this._treeNodeOver=function(obj){
		this.treeNodeOver(obj,obj.value);
	}
	this.treeNodeOptionOver=function(obj,id,hasChild){}
	this._treeNodeOptionOver=function(obj){
		this.treeNodeOptionOver(obj,obj.value,obj.hasChild);
	}
}